package com.wt.admin.service.image.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wt.admin.code.image.ImageFeatures3000;
import com.wt.admin.domain.dto.image.ImageFeaturesDTO;
import com.wt.admin.domain.dto.image.ImageItemDTO;
import com.wt.admin.domain.entity.image.ImageFeaturesEntity;
import com.wt.admin.domain.vo.image.ImageFeaturesVO;
import com.wt.admin.domain.vo.image.ImageItemVO;
import com.wt.admin.mapper.image.ImageFeaturesMapper;
import com.wt.admin.service.image.ImageFeaturesService;
import com.wt.admin.util.AssertUtil;
import com.wt.admin.util.PageUtil;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;
import java.util.List;

@Service
public class ImageFeaturesServiceImpl extends ServiceImpl<ImageFeaturesMapper, ImageFeaturesEntity> implements ImageFeaturesService {

    @Resource
    private ImageFeaturesMapper imageFeaturesMapper;

    @Override
    public ImageFeaturesVO add(ImageFeaturesDTO data) {
        AssertUtil.Str.isEmpty(data.getFeaturesName(), ImageFeatures3000.CODE_3000);
        AssertUtil.objIsNull(data.getLanguageClassificationId(), ImageFeatures3000.CODE_3001);
        save(data);
        return null;
    }

    @Override
    public PageUtil.PageVO<ImageFeaturesVO> list(PageUtil.PageDTO<ImageFeaturesDTO> data) {
        return PageUtil.findPage(data, (page) -> imageFeaturesMapper.page(page,data.getData()));
    }

    @Override
    public ImageFeaturesVO del(ImageFeaturesDTO data) {
        AssertUtil.objIsNull(data.getId(), ImageFeatures3000.CODE_3002);
        removeById(data);
        return null;
    }

    @Override
    public ImageFeaturesVO edit(ImageFeaturesDTO data) {
        AssertUtil.objIsNull(data.getId(), ImageFeatures3000.CODE_3002);
        updateById(data);
        return null;
    }

    @Override
    public List<ImageFeaturesVO> featuresList(ImageItemDTO data) {
        return imageFeaturesMapper.featuresListByLanguageClassificationId(data);
    }

}
